//
//  BannerDetailVC.swift
//  HelloSwift
//
//  Created by alankong on 2016/11/18.
//  Copyright © 2016年 tuotiansudai. All rights reserved.
//

import UIKit

class BannerDetailVC: UIViewController, UIWebViewDelegate {

    var url:String = ""
    let webView:UIWebView = UIWebView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "正在载入..."
        
        setupViews()
    }
    
    func setupViews() {
        self.view.addSubview(self.webView)
        self.webView.frame = self.view.bounds
        webView.delegate = self;
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        openRequest()
    }
    
    func openRequest() {
        let request:NSMutableURLRequest = NSMutableURLRequest();
        request.url = URL(string: url)
        self.webView.loadRequest(request as URLRequest)
    }
    
    func webViewDidFinishLoad(_ webView: UIWebView) {
        let title: String = (self.webView.stringByEvaluatingJavaScript(from: "document.title"))!
        self.title = title;
    }
}
